package com.yx.cloud.product.laser.inxni;

import android.content.Context;
import android.content.SharedPreferences;

import com.aaa.async.Promise;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.iot.product.sweeper.config.SweeperProductConfig;
import com.yx.cloud.MyApplication;
import com.yx.cloud.R;
import com.yx.cloud.bean.RobotIconColorBean;
import com.yx.cloud.product.ProductManager;
import com.iot.product.sweeper.bean.Robot;
import com.iot.product.sweeper.bean.RobotStatus;
import java.util.List;

public class X3 {

//    private X3() {
//        series.clear();
//        series.add(ProductManager.INXNI_X3_01);
//        series.add(ProductManager.INXNI_X3_03);
//    }
//
//    public static X3 get() {
//        return InstanceHoder.instance;
//    }
//
//    @Override
//    public void initConfig() {
//        config = new X3Config();
//        config.productGuide = "X3";
//        config.productName = "X3";
//        config.default_robotName = "花花";
//        config.product_type = ProductConfigConstants.PRODUCT_TYPE_LASER;
//        config.isInxni = true;
//        //地图
//        config.minCleanAreaSize = 0.5f;
//        config.minForbiddenAreaSize = 0.5f;
//        config.canRotateCleanArea = false;
//        config.maxAlarmCount = 10;
//
//        config.isEditMapNeedPauseRecharge = true;
//        config.isEditCustomNeedPause = true;
//
//        //右侧菜单
//        config.hasDustCollectingBarrel = false;   //集尘桶
//        config.hasConsumablesMaintain = true;    //耗材维护
//        config.hasMopDry = false;                 //拖布风干
//        config.hasFirmwareAutoUpdate = true;//固件自动更新
//        config.customerService = true;////客服跳转图标
//
//        config.robotIconId = R.mipmap.robot_icon_pic_x3;
//        config.robot_Airview = R.mipmap.main_x3_white_icon; //扫地斜俯视图  /main_x3_pink_icon/main_x3_purple_icon/main_x3_green_icon
//        config.robot_Preview = R.mipmap.robot_icon_pic_x3; //扫地机俯视图
//        config.robot_Virtual = R.mipmap.robot_icon_x3;
//        config.robot_light_images = new int[]{R.drawable.x3_white_light, R.drawable.x3_pink_light, R.drawable.x3_red_light};
//        config.hasMultiStyle = true;//切换机器图标颜色
//
//        config.cleanSetting_chooseRoom = true;//选择房间
//        config.cleanSetting_spotClean = false;//局部清扫
//        config.cleanSetting_edgeClean = false;//沿墙清扫
//        config.cleanSetting_quickClean = false;//快速清扫
//        config.cleanSetting_customMode = true;//定制模式
//        config.cleanSetting_sterilizeMode = false;//杀菌模式
//        config.cleanSetting_fineRub = false;//精擦模式
//        config.cleanSetting_noneSuction = false;//吸力第一个
//        config.cleanSetting_selfCleaningFrequency = false;//回洗频率
//        config.cleanSetting_carpetPressurization = false;//地毯增压
//        config.cleanSetting_hasDryMop = false;//基站水量第一个
//        config.cleanSetting_mopWater = true;//拖地 布局
//        config.cleanSetting_suction = true;//吸力布局
//        config.cleanSetting_isConbineWaterTankAndDustBox = false;
//
//        config.robotSetting_volume = true;
//        config.robotSetting_break_continue = true;
//        config.robotSetting_no_disturb = true;
//        config.robotSetting_silent = false;
//        config.robotSetting_factoryset = false;
//        config.robotSetting_light = false;
//        //X3s多一个水箱滤网
//        config.consumable_waterStrainer = 150 * 3600;//水箱滤网
//
//        config.backStopControl = true;
//        config.rechargeStopControl = true;
//        config.spotCleanStopControl = false;
//    }
/*

    @Override
    public Promise<?, TuyaSdkException> continueSweep(CleanParam param) {
        if (param != null) {
            int cleanType = param.getType();
            if (cleanType == RobotStatus.MODE_CUSTOM_CLEAN) {
                return zoneClean(param);//划区清扫
            }
        }
        return super.continueSweep(param);
    }
*/

    static class InstanceHoder {
        private static final X3 instance = new X3();
    }

    static class X3Config extends SweeperProductConfig {

        @Override
        public int getRobotAirview(Robot robot) {
            SharedPreferences sp = MyApplication.get().getSharedPreferences("SP_ROBOT_ICON", Context.MODE_PRIVATE);
            String peopleListJson = sp.getString("KEY_RobotIcon_LIST_DATA", "");
            int iconId = R.mipmap.main_x3_white_icon;
            if (peopleListJson != "")  //防空判断
            {
                Gson gson = new Gson();
                List<RobotIconColorBean> mList = gson.fromJson(peopleListJson, new TypeToken<List<RobotIconColorBean>>() {
                }.getType());
                if (mList != null) {
                    String connect_deviceId = robot.getDeviceId();
                    for (int i = 0; i < mList.size(); i++) {
                        if (mList.get(i).getDeviceId().equals(connect_deviceId)) {
                            String color = mList.get(i).getIsICutoverColor();
                            if (color != null) {
                                if ("blue".equals(color)) {
                                    iconId = R.mipmap.main_x3_purple_icon;
                                } else if ("pink".equals(color)) {
                                    iconId = R.mipmap.main_x3_pink_icon;
                                } else {
                                    iconId = R.mipmap.main_x3_white_icon;
                                }
                            }
                            break;
                        }
                    }
                }
            }
            return iconId;
        }
    }
}
